//获取应用实例
var sliderWidth = 96; 
var app = getApp();
Page({
  data: {
    tabs: ["全部", "已完成", "未完成"],
    activeIndex: 1,
    sliderOffset: 0,
    sliderLeft: 0,
    nickName: '',
    orderlist:'',
    allorder:'',
    completeorder:'',
    incompleteorder:'',
    url:''
  },
  // 加载
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: '订单管理'
    })
    var that = this
    //更新数据
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
      }
    });
    that.setData({
      nickName: app.globalData.userInfo.nickName,
      url: app.globalData.userInfo.avatarUrl
    })
    wx.request({
      url: 'https://www.hkzhaoscut.top/getorder',
      data:{
        u_id:wx.getStorageSync("openid")
      },
      success:function(res){
            that.setData({
              allorder:res.data,
              orderlist:res.data
            })
      }
    })
    wx.request({
      url: 'https://www.hkzhaoscut.top/getunfinishorder',
      data:{
        u_id:wx.getStorageSync("openid")
      },
      success:function(res){
        that.setData({
            incompleteorder : res.data
             
        });
        
      }

    })
    wx.request({
      url: 'https://www.hkzhaoscut.top/getfinishorder',
      data:{
        u_id:wx.getStorageSync("openid")
      },
      success:function(res){
        that.setData({ completeorder: res.data})
       
       
      }

    })
    
  
  },
  tabClick: function (e) {
    this.setData({
      sliderOffset: e.currentTarget.offsetLeft,
      activeIndex: e.currentTarget.id
    });
  }
})